home *** CD-ROM | disk | FTP | other *** search
- Path: in-news.erinet.com!usenet
- From: timb@erinet.com (Tim Berens)
- Newsgroups: comp.lang.c
- Subject: Re: Settle a bet please
- Date: Wed, 03 Apr 1996 22:03:45 GMT
- Organization: EriNet Online 513 436-9915
- Message-ID: <4jufbc$erj@eri.erinet.com>
- References: <4jfopb$o9n@news1.sympatico.ca> <4jh8rtINNosd@mayne.ugrad.cs.ubc.ca> <4jp8li$ue@eri2.erinet.com> <828542716snz@genesis.demon.co.uk>
- NNTP-Posting-Host: edlp162.erinet.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- Lawrence Kirby <fred@genesis.demon.co.uk> wrote:
-
- >In article <4jp8li$ue@eri2.erinet.com> timb@erinet.com "Tim Berens" writes:
-
- >>Here's an interesting way to decide for yourselves:
- >>
- >>main()
- >>{
- >> printf("size is: %d",sizeof("My Name"));
- >>}
-
- >Better make that:
-
- > printf("size is: %d",(int)sizeof("My Name"));
-
- >I'll hazard a guess that sizeof("My Name") fits in an int. :-)
-
- >>This will display how many bytes your compiler thinks should be
- >>allocated for "My Name"
-
- >Remember sizeof doesn't produce a result of type int, rather size_t which
- >is some implementation-dependent unsigned type.
-
- >--
- >-----------------------------------------
- >Lawrence Kirby | fred@genesis.demon.co.uk
- >Wilts, England | 70734.126@compuserve.com
- >-----------------------------------------
-
-
- Do people participate in this newsgroup simply to show their smarts by
- desperately seeking nits to pick?
-
- Also, even though it is remotely possible that size_t is not the same
- size as an int and that the compiler may not automatically cast it to
- an int for the function call Or that the size of "My name" will exceed
- 32K and size_t will be a 2 byte unsigned integer, does it really
- matter in this example? Can you name a compiler where
- printf("size=%d",sizeof("My Name")); will not properly display
- "size=8"?
-
-
-
-
-
-